home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.1 KB | 236 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrwPrmse.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef DRWPRMSE_H
- #include "DrwPrmse.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWSEL_H
- #include "DrawSel.h"
- #endif
-
- #ifndef BASESHP_H
- #include "BaseShp.h"
- #endif
-
- #ifndef BOUNDSHP_H
- #include "BoundShp.h"
- #endif
-
- #ifndef LINESHP_H
- #include "LineShp.h"
- #endif
-
- #ifndef OVALSHP_H
- #include "OvalShp.h"
- #endif
-
- #ifndef RECTSHP_H
- #include "RectShp.h"
- #endif
-
- #ifndef RRECTSHP_H
- #include "RRectShp.h"
- #endif
-
- #ifndef TEXTSHP_H
- #include "TextShp.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWORDCOL_H
- #include "FWOrdCol.h"
- #endif
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWPRISTR_H
- #include "FWPriStr.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWMEMHLP_H
- #include "FWMemHlp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdraw
- #endif
-
- //========================================================================================
- // class CDrawPromise
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawPromise::CDrawPromise
- //----------------------------------------------------------------------------------------
-
- CDrawPromise::CDrawPromise(Environment*ev, ODUpdateID updateID, FW_EStorageKinds storageKind, CDrawPart* part, FW_CFrame* scopeFrame, CDrawSelection* selection) :
- FW_CPromise(ev, updateID, storageKind, part, scopeFrame),
- fDrawSelection(selection),
- fCollection(NULL)
- {
- fDrawSelection->GetDragRect(fSelectionRect);
-
- fCollection = new FW_CPrivOrderedCollection;
-
- FW_COrderedCollectionIterator ite(part->GetShapeList());
- for (CBaseShape *shape = (CBaseShape*)ite.First(); ite.IsNotComplete(); shape = (CBaseShape*)ite.Next())
- {
- if (shape->IsSelectedShape())
- {
- shape->Promised(storageKind, TRUE);
- fCollection->AddLast(shape);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPromise::~CDrawPromise
- //----------------------------------------------------------------------------------------
-
- CDrawPromise::~CDrawPromise()
- {
- if (fCollection)
- {
- Environment* ev = somGetGlobalEnvironment();
-
- FW_COrderedCollectionIterator ite(fCollection);
- for (CBaseShape *shape = (CBaseShape*)ite.First(); ite.IsNotComplete(); shape = (CBaseShape*)ite.Next())
- {
- shape->Promised(GetStorageKind(ev), FALSE);
- }
-
- delete fCollection; // Will call RemoveAll
- fCollection = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPromise::PromisePropertiesAndValues
- //----------------------------------------------------------------------------------------
-
- void CDrawPromise::PromisePropertiesAndValues(Environment *ev, ODStorageUnit* storageUnit)
- {
- FW_CPromise::PromisePropertiesAndValues(ev, storageUnit); // kODPropContents with the part kind value
-
- #ifdef FW_BUILD_MAC
- this->Promise(ev, storageUnit, kODPropContents, FW_CPart::gMacPICTDataType);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPromise::FulfillPromise
- //----------------------------------------------------------------------------------------
-
- void CDrawPromise::FulfillPromise(Environment *ev,
- ODStorageUnitView *promiseSUView,
- ODPropertyName propertyName,
- ODValueType valueType,
- FW_CCloneInfo* cloneInfo)
- {
- FW_ASSERT(FW_PrimitiveStringEqual(propertyName, kODPropContents));
- if (FW_PrimitiveStringEqual(valueType, GetPart(ev)->GetPartKind(ev)))
- {
- // ----- Create an archive object -----
- FW_CStorageUnitSink sink(promiseSUView);
- CDrawWritableStream archive(ev, &sink, cloneInfo);
-
- // ----- Write number of shapes -----
- unsigned long count = fCollection->Count();
- archive << count;
-
- // ----- Write top left offset -----
- archive << fSelectionRect.left;
- archive << fSelectionRect.top;
-
- // ----- Clone the contents of the selection -----
- FW_COrderedCollectionIterator ite(fCollection);
- for (CBaseShape *shape = (CBaseShape*)ite.First(); ite.IsNotComplete(); shape = (CBaseShape*)ite.Next())
- {
- if (shape->IsPromised(GetStorageKind(ev)))
- FW_WRITE_DYNAMIC_OBJECT(archive, shape, CBaseShape);
- }
- }
- else if (FW_PrimitiveStringEqual(valueType, FW_CPart::gMacPICTDataType))
- {
- FW_PPicture picture;
-
- {
- FW_CPictureContext pc(ev, picture, fSelectionRect.Width(), fSelectionRect.Height());
-
- // ----- Clone the contents of the selection -----
- FW_COrderedCollectionIterator ite(fCollection);
- for (CBaseShape *shape = (CBaseShape*)ite.First(); ite.IsNotComplete(); shape = (CBaseShape*)ite.Next())
- {
- if (shape->GetShapeType() != kProxyShape)
- {
- shape->OffsetShape(ev, -fSelectionRect.left, -fSelectionRect.top);
- shape->RenderShape(ev, NULL, pc);
- shape->OffsetShape(ev, fSelectionRect.left, fSelectionRect.top);
- }
- }
- }
-
- FW_PlatformPict platformPict = picture->GetPlatformPict();
-
- unsigned long pictSize = FW_CMemoryManager::GetSystemHandleSize((FW_PlatformHandle)platformPict);
-
- FW_CAcquireLockedSystemHandle lockedHandle((FW_PlatformHandle)platformPict);
-
- FW_CStorageUnitSink sink(promiseSUView);
- FW_CWritableStream stream(&sink);
- stream.Write(lockedHandle.GetPointer(), pictSize);
- }
- #ifdef FW_DEBUG
- else
- FW_DEBUG_MESSAGE("CDrawDesignator::Externalize - Unknown type");
- #endif
- }
-